
** set path
// gl path ""

** open log
cap log close
log using "$path/table2.log", replace

***** Descriptive statistics for ohio individual-level analysis
use foreclose g_ dem rep ind reg_year using "$path/turnout_analysis.dta", clear

sum foreclose
local m1 = r(mean)
local sd1 = r(sd)
local min1 = r(min)
local max1 = r(max)
local n1 = r(N)

sum g_
local m2 = r(mean)
local sd2 = r(sd)
local min2 = r(min)
local max2 = r(max)
local n2 = r(N)

sum dem
local m3 = r(mean)
local sd3 = r(sd)
local min3 = r(min)
local max3 = r(max)
local n3 = r(N)

sum rep
local m4 = r(mean)
local sd4 = r(sd)
local min4 = r(min)
local max4 = r(max)
local n4 = r(N)

sum ind
local m5 = r(mean)
local sd5 = r(sd)
local min5 = r(min)
local max5 = r(max)
local n5 = r(N)


keep if reg_year <= 2003


sum foreclose
local m6 = r(mean)
local sd6 = r(sd)
local min6 = r(min)
local max6 = r(max)
local n6 = r(N)

sum g_
local m7 = r(mean)
local sd7 = r(sd)
local min7 = r(min)
local max7 = r(max)
local n7 = r(N)

sum dem
local m8 = r(mean)
local sd8 = r(sd)
local min8 = r(min)
local max8 = r(max)
local n8 = r(N)

sum rep
local m9 = r(mean)
local sd9 = r(sd)
local min9 = r(min)
local max9 = r(max)
local n9 = r(N)

sum ind
local m10 = r(mean)
local sd10 = r(sd)
local min10 = r(min)
local max10 = r(max)
local n10 = r(N)

log close


quietly {
	cap log close
	set linesize 255
	log using "$path/descriptive_ohio.tex", text replace
	
	noisily dis "\begin{table}[t]"
	noisily dis "\centering"
	noisily dis "\caption{\textbf{Descriptive Statistics, Individual Level, Ohio, 2004--2016.}"
	noisily dis "\label{tab:descriptive_ohio}}"
	noisily dis "\begin{tabular}{lccc}"
	noisily dis "\toprule \toprule"
	
	noisily dis " &  & Standard &  \\"
	noisily dis " & Mean & Deviation & Observations \\"
	noisily dis " & (1) & (2) & (3) \\[0mm]"
	noisily dis "\midrule"
	noisily dis " & \multicolumn{3}{c}{A. Full Voter File} \\\cline{2-4}\\[-2mm]"
	noisily dis " Prob of Foreclosure & " %4.3f `m1' " & " %4.3f `sd1'  " & " %12.0fc `n1' " \\"
	noisily dis " Turnout Rate & " %4.2f `m2' " & " %4.2f `sd2'  " & " %12.0fc `n2' " \\"
	noisily dis " Dem Registration \% & " %4.2f `m3' " & " %4.2f `sd3' " & " %12.0fc `n3' " \\"
	noisily dis " Rep Registration \% & " %4.2f `m4' " & " %4.2f `sd4'  " & " %12.0fc `n4' " \\"
	noisily dis " Ind Registration \% & " %4.2f `m5' " & " %4.2f `sd5'  " & " %12.0fc `n5' " \\\cline{2-4}\\[-4mm]"

	noisily dis " & \multicolumn{3}{c}{B. Registered Before 2004} \\\cline{2-4}\\[-2mm]"
	noisily dis " Prob of Foreclosure & " %4.3f `m6' " & " %4.3f `sd6' " & " %12.0fc `n6' " \\"
	noisily dis " Turnout Rate & " %4.2f `m7' " & " %4.2f `sd7' " & " %12.0fc `n7' " \\"
	noisily dis " Dem Registration \% & " %4.2f `m8' " & " %4.2f `sd8' " & " %12.0fc `n8' " \\"
	noisily dis " Rep Registration \% & " %4.2f `m9' " & " %4.2f `sd9'  " & " %12.0fc `n9' " \\"
	noisily dis " Ind Registration \% & " %4.2f `m10' " & " %4.2f `sd10'  " & " %12.0fc `n10' " \\"

	noisily dis "\bottomrule \bottomrule"
	noisily dis "\multicolumn{4}{p{.6\textwidth}}{\scriptsize \emph{Note: } Panel A presents summary statistics for all individuals who appear either in Ohio's voter"
	noisily dis " file or in the Ohio foreclosure records.  Panel B presents these same summary statistics only for individuals "
	noisily dis "who registered to vote prior to the timeframe of our study.  The unit of analysis for all rows is an "
	noisily dis "individual-year pair.  An individual is marked as foreclosed on if she experienced at least one foreclosure"
	noisily dis " at any time in the year up to the election date in early November.  Turnout rate is measured as the "
	noisily dis "percentage of all individuals in the dataset who are marked as turning out in the general election.  "
	noisily dis "Dem, Rep, and Ind registration percentages are calculated using party registration as provided in "
	noisily dis "the Ohio voter file, and reflect the proportion of registered voters who register with each party.  "
	noisily dis "A negligible number of Ohio voters register for third parties.  The number of observations in Panel A "
	noisily dis "is slightly larger for foreclosures and turnout rate than for the party registration variables because "
	noisily dis "we include foreclosed individuals who do not register to vote.  These individuals are not included in "
	noisily dis "Panel B, so all sample sizes in Panel B are equal.}"
	noisily dis "\end{tabular}"
	noisily dis "\end{table}"
	
	log off
	
}
